//
//  ClubInfoBottomCell.m
//  SportSocial
//
//  Created by yull on 15/1/10.
//  Copyright (c) 2015年 yull. All rights reserved.
//

#import "PlaceInfoBottomCell.h"
#import "NSString+Size.h"

@implementation PlaceInfoBottomCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = [UIColor whiteColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.separatorInset = UIEdgeInsetsMake(0, SCREEN_WIDTH, 0, 0);
        
        CGRect rect = CGRectMake(10, 15, 200, 15);
        self.tagLabel = [[UILabel alloc] initWithFrame:rect];
        self.tagLabel.backgroundColor = [UIColor clearColor];
        self.tagLabel.font = [UIFont systemFontOfSize:15.0f];
        self.tagLabel.textColor = [UIColor grayColor];
        self.tagLabel.text = @"场馆简介:";
        [self.contentView addSubview:self.tagLabel];
        
        rect = CGRectMake(20, self.tagLabel.bottom + 15, self.contentView.width - 20 * 2, 0);
        self.clubDetailLabel = [[UILabel alloc] initWithFrame:rect];
        self.clubDetailLabel.backgroundColor = [UIColor clearColor];
        self.clubDetailLabel.font = [UIFont systemFontOfSize:14.0f];
        self.clubDetailLabel.textColor = self.tagLabel.textColor;
        self.clubDetailLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
        self.clubDetailLabel.numberOfLines = 0;
        [self.contentView addSubview:self.clubDetailLabel];
    }
    return self;
}

+ (CGFloat)calulateCellHeightWithText:(NSString *)text
{
    CGSize constrainedSize = CGSizeMake(SCREEN_WIDTH - 40, CGFLOAT_MAX);
    CGSize textSize = [text getSizeWithFont:[UIFont systemFontOfSize:14.0f] constrainedSize:constrainedSize];
    return textSize.height + 45;
}

- (void)drawCellWithText:(NSString *)text
{
    self.clubDetailLabel.text = text;
    
    CGSize constrainedSize = CGSizeMake(SCREEN_WIDTH - 40, CGFLOAT_MAX);
    CGSize textSize = [text getSizeWithFont:[UIFont systemFontOfSize:14.0f] constrainedSize:constrainedSize];
    self.clubDetailLabel.height = textSize.height;
}
@end
